package com.kylin.androidlearn1.acticity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.kylin.androidlearn1.R;

public class ActivityPhone extends Activity {

    private EditText input;
    private Button mBtCall;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_phone);

        TextView hint = (TextView) findViewById(R.id.call_hint);
        hint.setText("新利  ");
        hint.setTextColor(Color.GREEN);

        input = (EditText) findViewById(R.id.call_input_EditText);

        mBtCall = (Button) findViewById(R.id.bt_call);
        mBtCall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //1 获取手机号
                String phone = input.getText().toString();
                //2 呼叫
                //用intent启动拨打电话
                Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
                ActivityPhone.this.startActivity(intent);
                Toast.makeText(ActivityPhone.this,"mBtCall phoneNumber: "+phone ,Toast.LENGTH_LONG).show();
            }
        });

    }
}
